package Demo35;

/**
 * 判断字符是否唯一
 * https://leetcode.cn/problems/is-unique-lcci/
 */
class Solution {
    public boolean isUnique(String astr) {
        int len = astr.length();
        int hash = 0;
        for(int i = 0; i < len;i++) {
            int ch = astr.charAt(i) - 'a';
            if((hash & (1 << ch)) != 0) {
                return false;
            }
            hash |= (1 << ch);
        }
        return true;
    }
}
class Demo {
    public static void main(String[] args) {
        Solution solution = new Solution();
        boolean ret = solution.isUnique("abaa");
        System.out.println(ret);
    }
}